# 基于node:18.19-slim镜像
FROM node:18.19-slim as builder

RUN pwd
RUN ls


# 设置工作目录
WORKDIR /home/jenkins/agent/workspace/homeland

RUN pwd
RUN ls ..
RUN ls

# 复制项目文件到工作目录
COPY . .

RUN pwd
RUN ls

RUN npm config set registry http://registry.npmmirror.com
# 安装项目依赖，并使用镜像加速
RUN npm install

# 构建项目
RUN npm run build --prod

# 基于nginx镜像
FROM nginx:1.25.3-alpine

RUN mkdir -p /usr/share/nginx/html/homeland
# 复制构建好的项目文件到nginx的html目录
COPY --from=builder /home/jenkins/agent/workspace/homeland/dist/angular-first-app/browser /usr/share/nginx/html/homeland

# 设置用户标签
LABEL maintainer="Homeland"

# 复制nginx配置文件到nginx的conf.d目录
COPY ./nginx-angular.conf /etc/nginx/conf.d/default.conf
